<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>意无瑕</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="fly,layui,前端社区">
    <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/static/css/app.css}">
</head>
<body>

<form class="layui-form" action="">
    <div class="mark-text">
        <p th:text="${userName}" style="color: red;"></p>
    </div>
    <div class="mark-text">
        上班打卡:
    </div>
    <div class="mark-text">
        当前时间:<span th:text="${nowHourMinute}"></span>
    </div>
    <div class="layui-form-item" style="margin-top: 10px;">
        <div class="layui-input-block">
            <button  type="button"  class="layui-btn layui-btn-normal" id="start-check">上班打卡</button>
        </div>
    </div>


</form>

<script th:src="@{/static/layui/layui.all.js}"></script>
<script>
    ;!function () {
        //无需再执行layui.use()方法加载模块，直接使用即可
        var form = layui.form
            , layer = layui.layer;
        $ = layui.jquery;


        $("#start-check").on('click', function () {
            $.ajax({
                url: '/work/startWork',
                method: 'post',
                data: {
                    type:0//上班
                },
                dataType: 'JSON',
                success: function (response) {
                    console.log(response);
                    if (response.status==0){
                        layer.msg('上班打卡成功',{time:1000},function() {
                            layer.close(layer.index);
                            parent.location.reload();
                        });
                    }else{
                        layer.msg("打卡失败:"+response.msg);
                    }
                }
            });
        });
        $("#login-register").on('click',function(){
            layer.open({
                type: 2,
                shade: true,
                title: '用户注册',
                maxmin: false,
                skin: 'layui-layer-rim', //加上边框
                area: ['300px', '400px'], //宽高
                content: '/login/register',
                zIndex: layer.zIndex, //重点1

            });
        });

    }();
</script>
</body>
</html>